package cra.clima.gsrad;

import net.sf.xqore.log.XQLog;
import net.sf.xqore.math.XQMath;

import cra.clima.core.interfaces.gsrad.IAGSRadStrategy;
import cra.clima.core.interfaces.gsrad.IRadData;
import cra.clima.core.interfaces.stat.IRandomizer;
import cra.clima.core.stat.DeterministicRandomizer;
import junit.framework.TestCase;

public class GSRadContextTest extends TestCase {
	private double delta;

	private XQLog logger;

	public GSRadContextTest() {
		super();
		delta = 0.1;
		this.logger = XQLog.getInstance(this.getClass());
	}

	public void TestInstance() {
		IAGSRadStrategy algo = new GSRBristowCampbellStrategy();
		GSRadContext gsrc = new GSRadContext(algo);
		assertNotNull("I am an object", gsrc);
		assertTrue("I am an instance of GSRadContext",
				gsrc instanceof GSRadContext);

	}

	public void testSlopeAspect() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();
		logger.debug("Create istance of GSRadContext class ");
		// GSRadContext gsr = new GSRadContext();

		logger
				.debug("Fill the necessary input data for the Slope & Aspect algorithm");
		radData.setElevation(1.1, 0, 0);
		radData.setElevation(2.1, 0, 1);
		radData.setElevation(1.2, 0, 2);
		radData.setElevation(1.3, 1, 0);
		radData.setElevation(1.7, 1, 1);
		radData.setElevation(1.5, 1, 2);
		radData.setElevation(1.1, 2, 0);
		radData.setElevation(1.4, 2, 1);
		radData.setElevation(0.6, 2, 2);
		radData.setCellSize(3.3);

		logger
				.debug("Call the SlopeAspect method and pass the RadData istance");

		SASlopeAspectStrategy algo = new SASlopeAspectStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(radData);

		logger.debug("Get the result of the computation");
		assertEquals("angle slope is,", 0.2, radData.getAngleSlope(), delta);
		assertEquals("angle aspect is,", 0.3, radData.getAngleAspect(), delta);

	}

	public void testBristowCampbellAlgo() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();
		BristowCampbellParameters bcParams = new BristowCampbellParameters();

		logger
				.debug("Fill the necessary input data for the Bristow-Campbell algorithm");
		
		/* not longer needed to evaluate global solar radiation with Bristow-Campbell
		radData.setCurrentDay(1); // 1-365
		radData.setClearSkyTransmissivity(0.75); // 0.52-0.85
		radData.setLatitude(45); // -90-90
		*/
		
		radData.setExtraTerrestrialRadiation(20); // 0.05-42
		radData.setSlopeAspectFactor(1); // 0-3
		radData.setAirTemperatureDailyRange(15); // 1-25
		radData.setAirTemperatureMonthlyRange(15); // 1-25

		bcParams.setB(0.12); // 0.08-0.3
	

		logger
				.debug("Create istance of GSRBristowCampbellStrategy class that implements the Bristow-Campbell algorithm. This class implements the interface IAGSRadStrategy.");
		GSRBristowCampbellStrategy selectedAlgorithm = new GSRBristowCampbellStrategy();
		selectedAlgorithm.setParameters(bcParams);
		logger.debug("Create istance of GSRadContext class ");
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy) selectedAlgorithm);

		gsr.evaluate(radData);
		assertEquals("potential radiation is", 1.2, radData.getGlobalSolarRadiation(),
				delta);
	}

	public void testCampbellDonatelliAlgo() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();
		CampbellDonatelliParameters cdparams = new CampbellDonatelliParameters();

		logger
				.debug("Fill the necessary input data for the Campbell-Donatelli algorithm");

		// radData.setCurrentDay(3);
		// radData.setLatitude(3.5);

		radData.setClearSkyTransmissivity(0.75); //0.52-0.85
		radData.setAirTemperatureDailyRange(15); //1-25
		radData.setAirTemperatureDailyAverage(15); //-17-43
		radData.setAirTemperatureMin(4); // ??? 
		radData.setSlopeAspectFactor(1); // 0-3
		radData.setExtraTerrestrialRadiation(20); // 0.05-42
		
		cdparams.setB(0.3); // 0.08-0.6
		cdparams.setTnc(80); // 10-110
		
		logger
				.debug("Create istance of GSRCampbellDonatelliStategy class that implements the Campbell-Donatelli algorithm. This class implements the interface IAGSRadStrategy.");
		GSRCampbellDonatelliStategy selectedAlgorithm = new GSRCampbellDonatelliStategy();
		selectedAlgorithm.setParameters(cdparams);
		logger.debug("Create istance of GSRadContext class ");
		GSRadContext gsr = new GSRadContext(selectedAlgorithm);

		gsr.evaluate(radData);
	}

	public void testDonatelliBellocchiAlgo() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();
		DonatelliBellocchiParameters params = new DonatelliBellocchiParameters();

		logger
				.debug("Fill the necessary input data for the Donatelli-Bellocchi algorithm");
		radData.setCurrentDay(2);
		radData.setClearSkyTransmissivity(0.75);
		radData.setLatitude(45);
		radData.setAirTemperatureDailyRange(1.2);
		radData.setAirTemperatureWeeklyRange(15);

		params.setB(0.2);
		params.setC1(0.01);
		params.setC2(0.01);
		params.setReverse(false);

		logger
				.debug("Create istance of GSRDonatelliBellocchiStrategy class that implements the Donatelli-Bellocchi algorithm. This class implements the interface IAGSRadStrategy.");
		GSRDonatelliBellocchiStrategy selectedAlgorithm = new GSRDonatelliBellocchiStrategy();
		selectedAlgorithm.setParameters(params);
		logger.debug("Create istance of GSRadContext class ");
		GSRadContext gsr = new GSRadContext(selectedAlgorithm);

		// logger.debug("Call the method for the computation of
		// extra-terrestrial radiation");
		// gsr.potentialRadiation(radData);
		// logger.debug("Call the method for the computation of GSR using the
		// selected algorithm.");
		// gsr.groundRadiation(radData);
		gsr.evaluate(radData);
		assertEquals("potential radiation is", 1.2, radData.getGlobalSolarRadiation(),
				delta);

	}

	

	public void testRichardsonAlgo() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();

		logger.debug("Create Parameters needed for richardson");
		RichardsonParameters rParams = new RichardsonParameters();

		logger
				.debug("Fill the necessary input data for the algorithm. Most of the input data are hard-coded.");
	
		radData.setGlobalSolarRadiationResidual(0); // -5-+5
		
		rParams.setRadiationMonthlyAverage(20); // 0.1 - 35
		rParams.setRadiationMonthlyStandardDeviation(1); // 0-5
		rParams.setNumberOfDaysInMonth(30); // 28-31
		rParams.setNumberOfWetDaysInMonth(10); // 0-31 < N
		rParams.setScalingFactorWetDry(0.5); // 0-1
		rParams.setSelectedState(StateEnum.State_Dry); // wet-dry
		rParams.setSelectedMethod(MethodEnum.Method_Separated); // separated-noseparated


		
		logger
				.debug("Create istance of SSDStrategy class that implements the Richardson algorithm. This class implements the interface IAGSRadStrategy.");
		GSRRichardsonStrategy selectedAlgorithm = new GSRRichardsonStrategy();
		selectedAlgorithm.setParameters(rParams);

		logger.debug("Create istance of GSRadContext class ");
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy) selectedAlgorithm);

		gsr.evaluate(radData);

		assertEquals("potential radiation is", 1.2, radData.getGlobalSolarRadiation(),
				delta);

	}
	
	
	public void testResidualRichardsonAlgo() {

		logger.debug("Create istance of RadData class ");
		IRadData radData = new RadData();

		logger.debug("Create Parameters needed for richardson");
		ResidualRichardsonParameters rrParams = new ResidualRichardsonParameters();

		logger
				.debug("Fill the necessary input data for the algorithm. Most of the input data are hard-coded.");
		rrParams.setSelectedState(StateEnum.State_Dry);
		rrParams.setSelectedMethod(MethodEnum.Method_Separated);
		rrParams.setAirTemperatureMaxDayBeforeResidual(0);
		rrParams.setAirTemperatureMinDayBeforeResidual(0);
		rrParams.setRadiationDayBeforeResidual(0);
		
		// A matrix
		rrParams.setA(0, 0, 0.567);
		rrParams.setA(0, 1, 0.086);
		rrParams.setA(0, 2, -0.00198);
		rrParams.setA(1, 0, 0.253);
		rrParams.setA(1, 1, 0.504);
		rrParams.setA(1, 2, -0.05);
		rrParams.setA(2, 0, 0.004231);
		rrParams.setA(2, 1, -0.041);
		rrParams.setA(2, 2, 0.244);

		// B matrix
		rrParams.setB(0, 0, 0.749);
		rrParams.setB(0, 1, 0.186);
		rrParams.setB(0, 2, 0.12);
		rrParams.setB(1, 1, 0.684);
		rrParams.setB(1, 2, -0.098);
		rrParams.setB(2, 2, 0.954);
		rrParams.setB(1, 0, rrParams.getB(0, 1));
		rrParams.setB(2, 0, rrParams.getB(0, 2));
		rrParams.setB(2, 1, rrParams.getB(1, 2));

		logger
				.debug("Create istance of SSDStrategy class that implements the Richardson algorithm. This class implements the interface IAGSRadStrategy.");
		GSRResidualRichardsonStrategy selectedAlgorithm = new GSRResidualRichardsonStrategy();
		selectedAlgorithm.setParameters(rrParams);

		logger.debug("Create istance of GSRadContext class ");
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy) selectedAlgorithm);

		gsr.evaluate(radData);

		assertEquals("global solar radiation residual is", 1.2, radData.getGlobalSolarRadiationResidual(),
				delta);

	}
	
	public void testSlopeAspect0() {
		IRadData rd = new RadData();
		
		// Parameters:
		rd.setElevation(10,0,0);
		rd.setElevation(10,0,1);
		rd.setElevation(10,0,2);
		
		rd.setElevation(12,1,0);
		rd.setElevation(12,1,1);
		rd.setElevation(12,1,2);
		
		rd.setElevation(13,2,0);
		rd.setElevation(13,2,1);
		rd.setElevation(13,2,2);
		
		rd.setCellSize(1);
		
		SASlopeAspectStrategy algo = new SASlopeAspectStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		
		gsr.evaluate(rd);
		assertEquals("Aspect:",0,rd.getAngleAspect(),delta);
		assertEquals("Slope:",56.3,XQMath.round(rd.getAngleSlope(),1),delta);
		
	}
	
	public void testSlopeAspect1() {
		IRadData rd = new RadData();
		
		// Parameters:
		rd.setElevation(12,0,0);
		rd.setElevation(15,0,1);
		rd.setElevation(15,0,2);
		
		rd.setElevation(12,1,0);
		rd.setElevation(12,1,1);
		rd.setElevation(15,1,2);
		
		rd.setElevation(12,2,0);
		rd.setElevation(12,2,1);
		rd.setElevation(13,2,2);
		
		rd.setCellSize(1);
		
		SASlopeAspectStrategy algo = new SASlopeAspectStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		
		gsr.evaluate(rd);
		assertEquals("Slope:",51,rd.getAngleSlope(),delta);
		assertEquals("Aspect:",38.7,rd.getAngleAspect(),delta);
		
	}
	
	public void testSlopeAspect2() {
		IRadData rd = new RadData();
		
		// Parameters:
		rd.setElevation(6,0,0);
		rd.setElevation(7,0,1);
		rd.setElevation(7,0,2);
		
		rd.setElevation(5,1,0);
		rd.setElevation(7,1,1);
		rd.setElevation(7,1,2);
		
		rd.setElevation(8,2,0);
		rd.setElevation(7,2,1);
		rd.setElevation(8,2,2);
		
		rd.setCellSize(1);
		
		SASlopeAspectStrategy algo = new SASlopeAspectStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		
		gsr.evaluate(rd);
		assertEquals("Slope:",36.1,XQMath.round(rd.getAngleSlope(),1),delta);
		assertEquals("Aspect:",301,XQMath.round(rd.getAngleAspect(),1),delta);
		
	}
	
	public void testResidualRichardson1() {
		IRadData rd = new RadData();
		ResidualRichardsonParameters rrParams = new ResidualRichardsonParameters();
		
		
		rrParams.setA(0, 0, 0.567);
		rrParams.setA(0, 1, 0.086);
		rrParams.setA(0, 2, -0.00198);
		rrParams.setA(1, 0, 0.253);
		rrParams.setA(1, 1, 0.504);
		rrParams.setA(1, 2, -0.05);
		rrParams.setA(2, 0, 0.004231);
		rrParams.setA(2, 1, -0.041);
		rrParams.setA(2, 2, 0.244);

		rrParams.setB(0, 0, 0.749);
		rrParams.setB(0, 1, 0.186);
		rrParams.setB(0, 2, 0.12);
		rrParams.setB(1, 1, 0.684);
		rrParams.setB(1, 2, -0.098);
		rrParams.setB(2, 2, 0.954);
		rrParams.setB(1, 0, rrParams.getB(0, 1));
		rrParams.setB(2, 0, rrParams.getB(0, 2));
		rrParams.setB(2, 1, rrParams.getB(1, 2));
		
		rrParams.setRadiationDayBeforeResidual(0);
		rrParams.setAirTemperatureMaxDayBeforeResidual(0);
		rrParams.setAirTemperatureMinDayBeforeResidual(0);
		rrParams.setSelectedMethod(MethodEnum.Method_Separated);
		rrParams.setSelectedState(StateEnum.State_Wet);
		
		double[] rvect = {0,1,0,1,0,1,0,1};
		IRandomizer randomizer = new DeterministicRandomizer(rvect);
		GSRResidualRichardsonStrategy algo = new GSRResidualRichardsonStrategy(randomizer);
		algo.setParameters(rrParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Residual Radiation",0,rd.getGlobalSolarRadiationResidual(),delta);
	}
	
	public void testResidualRichardson2() {
		IRadData rd = new RadData();
		ResidualRichardsonParameters rrParams = new ResidualRichardsonParameters();
		
		
		rrParams.setA(0, 0, 0.567);
		rrParams.setA(0, 1, 0.086);
		rrParams.setA(0, 2, -0.00198);
		rrParams.setA(1, 0, 0.253);
		rrParams.setA(1, 1, 0.504);
		rrParams.setA(1, 2, -0.05);
		rrParams.setA(2, 0, 0.004231);
		rrParams.setA(2, 1, -0.041);
		rrParams.setA(2, 2, 0.244);

		rrParams.setB(0, 0, 0.749);
		rrParams.setB(0, 1, 0.186);
		rrParams.setB(0, 2, 0.12);
		rrParams.setB(1, 1, 0.684);
		rrParams.setB(1, 2, -0.098);
		rrParams.setB(2, 2, 0.954);
		rrParams.setB(1, 0, rrParams.getB(0, 1));
		rrParams.setB(2, 0, rrParams.getB(0, 2));
		rrParams.setB(2, 1, rrParams.getB(1, 2));
		
		rrParams.setRadiationDayBeforeResidual(0);
		rrParams.setAirTemperatureMaxDayBeforeResidual(-3);
		rrParams.setAirTemperatureMinDayBeforeResidual(1);
		rrParams.setSelectedMethod(MethodEnum.Method_Separated);
		rrParams.setSelectedState(StateEnum.State_Wet);
		
		double[] rvect = {0,1,0,1,0,1,0,1};
		IRandomizer randomizer = new DeterministicRandomizer(rvect);
		GSRResidualRichardsonStrategy algo = new GSRResidualRichardsonStrategy(randomizer);
		algo.setParameters(rrParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Residual Radiation",-1.615,rd.getGlobalSolarRadiationResidual(),delta);
	}

	
	public void testResidualRichardson3() {
		IRadData rd = new RadData();
		ResidualRichardsonParameters rrParams = new ResidualRichardsonParameters();
		
		
		rrParams.setA(0, 0, 0.567);
		rrParams.setA(0, 1, 0.086);
		rrParams.setA(0, 2, -0.00198);
		rrParams.setA(1, 0, 0.253);
		rrParams.setA(1, 1, 0.504);
		rrParams.setA(1, 2, -0.05);
		rrParams.setA(2, 0, 0.004231);
		rrParams.setA(2, 1, -0.041);
		rrParams.setA(2, 2, 0.244);

		rrParams.setB(0, 0, 0.749);
		rrParams.setB(0, 1, 0.186);
		rrParams.setB(0, 2, 0.12);
		rrParams.setB(1, 1, 0.684);
		rrParams.setB(1, 2, -0.098);
		rrParams.setB(2, 2, 0.954);
		rrParams.setB(1, 0, rrParams.getB(0, 1));
		rrParams.setB(2, 0, rrParams.getB(0, 2));
		rrParams.setB(2, 1, rrParams.getB(1, 2));
		
		rrParams.setRadiationDayBeforeResidual(0);
		rrParams.setAirTemperatureMaxDayBeforeResidual(-3);
		rrParams.setAirTemperatureMinDayBeforeResidual(1);
		rrParams.setSelectedMethod(MethodEnum.Method_Separated);
		rrParams.setSelectedState(StateEnum.State_Wet);
		
		double[] rvect = {	0,1,0.5,0.13533,0.5,0.13533,0};
		IRandomizer randomizer = new DeterministicRandomizer(rvect);
		GSRResidualRichardsonStrategy algo = new GSRResidualRichardsonStrategy(randomizer);
		algo.setParameters(rrParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Residual Radiation",-2.227,rd.getGlobalSolarRadiationResidual(),delta);
	}
	
	public void testResidualRichardson4() {
		IRadData rd = new RadData();
		ResidualRichardsonParameters rrParams = new ResidualRichardsonParameters();
		
		
		rrParams.setA(0, 0, 0.567);
		rrParams.setA(0, 1, 0.086);
		rrParams.setA(0, 2, -0.00198);
		rrParams.setA(1, 0, 0.253);
		rrParams.setA(1, 1, 0.504);
		rrParams.setA(1, 2, -0.05);
		rrParams.setA(2, 0, 0.004231);
		rrParams.setA(2, 1, -0.041);
		rrParams.setA(2, 2, 0.244);

		rrParams.setB(0, 0, 0.749);
		rrParams.setB(0, 1, 0.186);
		rrParams.setB(0, 2, 0.12);
		rrParams.setB(1, 1, 0.684);
		rrParams.setB(1, 2, -0.098);
		rrParams.setB(2, 2, 0.954);
		rrParams.setB(1, 0, rrParams.getB(0, 1));
		rrParams.setB(2, 0, rrParams.getB(0, 2));
		rrParams.setB(2, 1, rrParams.getB(1, 2));
		
		rrParams.setRadiationDayBeforeResidual(0);
		rrParams.setAirTemperatureMaxDayBeforeResidual(-3);
		rrParams.setAirTemperatureMinDayBeforeResidual(1);
		rrParams.setSelectedMethod(MethodEnum.Method_Separated);
		rrParams.setSelectedState(StateEnum.State_Dry);
		
		double[] rvect = {	0,1,0.5,0.13533,0.5,0.13533,0};
		IRandomizer randomizer = new DeterministicRandomizer(rvect);
		GSRResidualRichardsonStrategy algo = new GSRResidualRichardsonStrategy(randomizer);
		algo.setParameters(rrParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Residual Radiation",-1.427,rd.getGlobalSolarRadiationResidual(),delta);
	}
	
	
	public void testGSRCampbellDonatelli() {
		IRadData rd = new RadData();
		CampbellDonatelliParameters cdParams = new CampbellDonatelliParameters();
		
		cdParams.setB(0.35);
		cdParams.setTnc(20);
		rd.setAirTemperatureDailyAverage(30);
		rd.setAirTemperatureDailyRange(16);
		rd.setClearSkyTransmissivity(0.75);
		rd.setExtraTerrestrialRadiation(20);
		rd.setAirTemperatureMin(22);
		rd.setSlopeAspectFactor(1);
		
		GSRCampbellDonatelliStategy algo = new GSRCampbellDonatelliStategy();
		algo.setParameters(cdParams);
		
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		assertEquals("Global solar radiation",14.95,rd.getGlobalSolarRadiation(),delta);
	}
	
	public void testSlopeAspectFactor1() {
		IRadData rd = new RadData();
		
		rd.setHourAngle(-180,0);
		rd.setHourAngle(-165,1);
		rd.setHourAngle(-150,2);
		rd.setHourAngle(-135,3);
		rd.setHourAngle(-120,4);
		rd.setHourAngle(-105,5);
		rd.setHourAngle(-90,6);
		rd.setHourAngle(-75,7);
		rd.setHourAngle(-60,8);
		rd.setHourAngle(-45,9);
		rd.setHourAngle(-30,10);
		rd.setHourAngle(-15,11);
		rd.setHourAngle(0,12);
		rd.setHourAngle(15,13);
		rd.setHourAngle(30,14);
		rd.setHourAngle(45,15);
		rd.setHourAngle(60,16);
		rd.setHourAngle(75,17);
		rd.setHourAngle(90,18);
		rd.setHourAngle(105,19);
		rd.setHourAngle(120,20);
		rd.setHourAngle(135,21);
		rd.setHourAngle(150,22);
		rd.setHourAngle(165,23);
		
		rd.setSolarElevation(0,0);
		rd.setSolarElevation(0,1);
		rd.setSolarElevation(0,2);
		rd.setSolarElevation(0,3);
		rd.setSolarElevation(0,4);
		rd.setSolarElevation(0.114,5);
		rd.setSolarElevation(0.281,6);
		rd.setSolarElevation(0.449,7);
		rd.setSolarElevation(0.606,8);
		rd.setSolarElevation(0.74,9);
		rd.setSolarElevation(0.843,10);
		rd.setSolarElevation(0.908,11);
		rd.setSolarElevation(0.93,12);
		rd.setSolarElevation(0.908,13);
		rd.setSolarElevation(0.843,14);
		rd.setSolarElevation(0.74,15);
		rd.setSolarElevation(0.606,16);
		rd.setSolarElevation(0.449,17);
		rd.setSolarElevation(0.281,18);
		rd.setSolarElevation(0.114,19);
		rd.setSolarElevation(0,20);
		rd.setSolarElevation(0,21);
		rd.setSolarElevation(0,22);
		rd.setSolarElevation(0,23);
		
		rd.setAngleAspect(180);
		rd.setAngleSlope(40);
		rd.setLatitude(45);
		rd.setSolarDeclination(0.409);
		
		rd.setHourSunrise(5);
		rd.setHourSunset(19);
	
		
		SAFSlopeAspectFactorStrategy algo = new SAFSlopeAspectFactorStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Slope Aspect Factor",0.736,rd.getSlopeAspectFactor(),delta);
		
	}
	
	public void testSlopeAspectFactor2() {
		IRadData rd = new RadData();
		
		rd.setHourAngle(-180,0);
		rd.setHourAngle(-165,1);
		rd.setHourAngle(-150,2);
		rd.setHourAngle(-135,3);
		rd.setHourAngle(-120,4);
		rd.setHourAngle(-105,5);
		rd.setHourAngle(-90,6);
		rd.setHourAngle(-75,7);
		rd.setHourAngle(-60,8);
		rd.setHourAngle(-45,9);
		rd.setHourAngle(-30,10);
		rd.setHourAngle(-15,11);
		rd.setHourAngle(0,12);
		rd.setHourAngle(15,13);
		rd.setHourAngle(30,14);
		rd.setHourAngle(45,15);
		rd.setHourAngle(60,16);
		rd.setHourAngle(75,17);
		rd.setHourAngle(90,18);
		rd.setHourAngle(105,19);
		rd.setHourAngle(120,20);
		rd.setHourAngle(135,21);
		rd.setHourAngle(150,22);
		rd.setHourAngle(165,23);
		
		rd.setSolarElevation(0,0);
		rd.setSolarElevation(0,1);
		rd.setSolarElevation(0,2);
		rd.setSolarElevation(0,3);
		rd.setSolarElevation(0,4);
		rd.setSolarElevation(0.114,5);
		rd.setSolarElevation(0.281,6);
		rd.setSolarElevation(0.449,7);
		rd.setSolarElevation(0.606,8);
		rd.setSolarElevation(0.74,9);
		rd.setSolarElevation(0.843,10);
		rd.setSolarElevation(0.908,11);
		rd.setSolarElevation(0.93,12);
		rd.setSolarElevation(0.908,13);
		rd.setSolarElevation(0.843,14);
		rd.setSolarElevation(0.74,15);
		rd.setSolarElevation(0.606,16);
		rd.setSolarElevation(0.449,17);
		rd.setSolarElevation(0.281,18);
		rd.setSolarElevation(0.114,19);
		rd.setSolarElevation(0,20);
		rd.setSolarElevation(0,21);
		rd.setSolarElevation(0,22);
		rd.setSolarElevation(0,23);
		
		rd.setAngleAspect(0);
		rd.setAngleSlope(0);
		rd.setLatitude(45);
		rd.setSolarDeclination(0.409);
		
		rd.setHourSunrise(5);
		rd.setHourSunset(19);
	
		
		SAFSlopeAspectFactorStrategy algo = new SAFSlopeAspectFactorStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("Slope Aspect Factor",1,rd.getSlopeAspectFactor(),delta);
		
	}
	
	public void testGSRJohnsonWoodward1() {
		IRadData rd = new RadData();
		JohnsonWoodwardParameters jwParams = new JohnsonWoodwardParameters();
		
		
		rd.setAngleSlope(0);
		rd.setClearSkyTransmissivity(0.75);
		rd.setDayLength(2.02);
		rd.setSlopeAspectFactor(1);
		rd.setSolarElevationAtNoon(0.01);
		rd.setSunshineDuration(1.02);
		
		jwParams.setCloudBlueFactor(1.0);
		
		GSRJohnsonWoodwardStrategy algo = new GSRJohnsonWoodwardStrategy();
		algo.setParameters(jwParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		assertEquals("global solar radiation",0,XQMath.round(rd.getGlobalSolarRadiation(),1),delta);
		
	}
	
	public void testGSRJohnsonWoodward2() {
		IRadData rd = new RadData();
		JohnsonWoodwardParameters jwParams = new JohnsonWoodwardParameters();
		
		
		rd.setAngleSlope(0);
		rd.setClearSkyTransmissivity(0.75);
		rd.setDayLength(8.99);
		rd.setSlopeAspectFactor(1);
		rd.setSolarElevationAtNoon(0.43);
		rd.setSunshineDuration(7.99);
		
		jwParams.setCloudBlueFactor(1.0);
		
		GSRJohnsonWoodwardStrategy algo = new GSRJohnsonWoodwardStrategy();
		algo.setParameters(jwParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		assertEquals("global solar radiation",8.2,XQMath.round(rd.getGlobalSolarRadiation(),1),delta);
		
	}
	
	public void testBDRLiuJordan1() {
		IRadData rd = new RadData();
		LiuJordanParameters ljParams = new LiuJordanParameters();
		
		ljParams.setLinkedTurbidityFactor(3);
		rd.setExtraTerrestrialRadiation(34);
		rd.setGlobalSolarRadiation(28);
		rd.setSlopeAspectFactor(1);
		rd.setElevation(0,1,1);
		rd.setClearSkyTransmissivity(0.75);
		rd.setAlbedo(0.2);
		
		BDRLiuJordanStrategy algo = new BDRLiuJordanStrategy();
		algo.setParameters(ljParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		assertEquals("Beam diffuse reflected",27.32,XQMath.round(rd.getRadiationBeam(),2),delta);
		assertEquals("Radiation reflected soil",0,XQMath.round(rd.getRadiationReflectedSoil(),2),delta);
		assertEquals("Radiation diffuse sky",0.68,XQMath.round(rd.getRadiationDiffuseSky(),2),delta);
	}
	
	
	public void testERExtraterrestrialRadiation() {
		IRadData rd = new RadData();
		
		rd.setCurrentDay(172);
		rd.setLatitude(-66);
		
		ERExtraterrestrialRadiationStrategy algo = new ERExtraterrestrialRadiationStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		assertEquals("Day Length",1.7,XQMath.round(rd.getDayLength(),1),delta);
		assertEquals("Extraterrestrial radiation",0,XQMath.round(rd.getExtraTerrestrialRadiation(),1),delta);
		assertEquals("Sunrise",11.1,XQMath.round(rd.getHourSunrise(),1),delta);
		assertEquals("Sunset",12.9,XQMath.round(rd.getHourSunset(),1),delta);
		assertEquals("Solar declination",0.409,XQMath.round(rd.getSolarDeclination(),3),delta);
		
	}
	
	public void testHGSRGlobalSolarRadiation() {
		IRadData rd = new RadData();
		
		rd.setGlobalSolarRadiation(28.13);
		rd.setExtraTerrestrialRadiationHourly(0,0);
		rd.setExtraTerrestrialRadiationHourly(0,1);
		rd.setExtraTerrestrialRadiationHourly(0,2);
		rd.setExtraTerrestrialRadiationHourly(0,3);
		rd.setExtraTerrestrialRadiationHourly(0,4);
		rd.setExtraTerrestrialRadiationHourly(0.54,5);
		rd.setExtraTerrestrialRadiationHourly(1.36,6);
		rd.setExtraTerrestrialRadiationHourly(2.22,7);
		rd.setExtraTerrestrialRadiationHourly(3.1,8);
		rd.setExtraTerrestrialRadiationHourly(3.97,9);
		rd.setExtraTerrestrialRadiationHourly(4.78,10);
		rd.setExtraTerrestrialRadiationHourly(5.42,11);
		rd.setExtraTerrestrialRadiationHourly(5.69,12);
		rd.setExtraTerrestrialRadiationHourly(5.42,13);
		rd.setExtraTerrestrialRadiationHourly(4.78,14);
		rd.setExtraTerrestrialRadiationHourly(3.97,15);
		rd.setExtraTerrestrialRadiationHourly(3.1,16);
		rd.setExtraTerrestrialRadiationHourly(2.22,17);
		rd.setExtraTerrestrialRadiationHourly(1.36,18);
		rd.setExtraTerrestrialRadiationHourly(0.54,19);
		rd.setExtraTerrestrialRadiationHourly(0,20);
		rd.setExtraTerrestrialRadiationHourly(0,21);
		rd.setExtraTerrestrialRadiationHourly(0,22);
		rd.setExtraTerrestrialRadiationHourly(0,23);
		
		HGSRGlobalSolarRadiationHourlyStrategy algo = new HGSRGlobalSolarRadiationHourlyStrategy();
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		double[] gsrh = {0,0,0,0,0,0.31,
						 0.79,1.29,1.8,2.3,2.77,3.15,3.3,
						 3.15,2.77,2.3,1.8,1.29,0.79,0.31,0,0,0,0
						 };
	
		for (int h=0;h<24;h++) {
			assertEquals("GSR at hour"+h+",",gsrh[h],XQMath.round(rd.getGlobalSolarRadiationHourly(h),2),delta);
		}
	}
	
	public void testGSRSupitVanKappel1() {
		IRadData rd = new RadData();
		SupitVanKappelParameters svkParams = new SupitVanKappelParameters();
		
		rd.setAirTemperatureDailyRange(15);
		rd.setExtraTerrestrialRadiation(17.45);
		rd.setSlopeAspectFactor(1);
		
		svkParams.setCloudCover(3);
		svkParams.setAdjustmentFactor(0);
		svkParams.setCloudCoverCoefficent(0.39);
		svkParams.setTemperatureRangeCoefficent(0.08);
		
		GSRSupitVanKappelStrategy algo = new GSRSupitVanKappelStrategy();
		algo.setParameters(svkParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("gsr:",10.8,XQMath.round(rd.getGlobalSolarRadiation(),1),delta);
		
	}
	
	public void testGSRSupitVanKappel2() {
		IRadData rd = new RadData();
		SupitVanKappelParameters svkParams = new SupitVanKappelParameters();
		
		rd.setAirTemperatureDailyRange(2);
		rd.setExtraTerrestrialRadiation(16.19);
		rd.setSlopeAspectFactor(1);
		
		svkParams.setCloudCover(8);
		svkParams.setAdjustmentFactor(0);
		svkParams.setCloudCoverCoefficent(0.39);
		svkParams.setTemperatureRangeCoefficent(0.08);
		
		GSRSupitVanKappelStrategy algo = new GSRSupitVanKappelStrategy();
		algo.setParameters(svkParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("gsr:",1.8,XQMath.round(rd.getGlobalSolarRadiation(),1),delta);
		
	}
	
	public void testGSRSupitVanKappel3() {
		IRadData rd = new RadData();
		SupitVanKappelParameters svkParams = new SupitVanKappelParameters();
		
		rd.setAirTemperatureDailyRange(1);
		rd.setExtraTerrestrialRadiation(6.67);
		rd.setSlopeAspectFactor(1);
		
		svkParams.setCloudCover(8);
		svkParams.setAdjustmentFactor(0);
		svkParams.setCloudCoverCoefficent(0.39);
		svkParams.setTemperatureRangeCoefficent(0.08);
		
		GSRSupitVanKappelStrategy algo = new GSRSupitVanKappelStrategy();
		algo.setParameters(svkParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("gsr:",0.5,XQMath.round(rd.getGlobalSolarRadiation(),1),delta);
		
	}
	
	public void testHBDRLiuJordanHourly1() {
		IRadData rd = new RadData();
		LiuJordanHourlyParameters ljhParams = new LiuJordanHourlyParameters();
		
		ljhParams.setHourlyLinkedTurbidityFactor(3);
		
		
		rd.setAlbedo(0.2);
		rd.setElevation(0,1,1); //Altitude  
		rd.setAngleSlope(0);
		rd.setClearSkyTransmissivity(0.75);
		rd.setCurrentDay(172);
		rd.setHourSunrise(5);
		rd.setHourSunset(19);
		
		rd.setGlobalSolarRadiationHourly(0,0);
		rd.setGlobalSolarRadiationHourly(0,1);
		rd.setGlobalSolarRadiationHourly(0,2);
		rd.setGlobalSolarRadiationHourly(0,3);
		rd.setGlobalSolarRadiationHourly(0,4);
		rd.setGlobalSolarRadiationHourly(0.36,5);
		rd.setGlobalSolarRadiationHourly(0.9,6);
		rd.setGlobalSolarRadiationHourly(1.43,7);
		rd.setGlobalSolarRadiationHourly(1.93,8);
		rd.setGlobalSolarRadiationHourly(2.36,9);
		rd.setGlobalSolarRadiationHourly(2.69,10);
		rd.setGlobalSolarRadiationHourly(2.89,11);
		rd.setGlobalSolarRadiationHourly(2.97,12);
		rd.setGlobalSolarRadiationHourly(2.9,13);
		rd.setGlobalSolarRadiationHourly(2.69,14);
		rd.setGlobalSolarRadiationHourly(2.36,15);
		rd.setGlobalSolarRadiationHourly(1.93,16);
		rd.setGlobalSolarRadiationHourly(1.43,17);
		rd.setGlobalSolarRadiationHourly(0.9,18);
		rd.setGlobalSolarRadiationHourly(0.36,19);
		rd.setGlobalSolarRadiationHourly(0,20);
		rd.setGlobalSolarRadiationHourly(0,21);
		rd.setGlobalSolarRadiationHourly(0,22);
		rd.setGlobalSolarRadiationHourly(0,23);
		
		rd.setSolarElevation(0,0);
		rd.setSolarElevation(0,1);
		rd.setSolarElevation(0,2);
		rd.setSolarElevation(0,3);
		rd.setSolarElevation(0,4);
		rd.setSolarElevation(0.114,5);
		rd.setSolarElevation(0.285,6);
		rd.setSolarElevation(0.466,7);
		rd.setSolarElevation(0.651,8);
		rd.setSolarElevation(0.833,9);
		rd.setSolarElevation(1.003,10);
		rd.setSolarElevation(1.138,11);
		rd.setSolarElevation(1.195,12);
		rd.setSolarElevation(1.138,13);
		rd.setSolarElevation(1.003,14);
		rd.setSolarElevation(0.833,15);
		rd.setSolarElevation(0.651,16);
		rd.setSolarElevation(0.466,17);
		rd.setSolarElevation(0.285,18);
		rd.setSolarElevation(0.114,19);
		rd.setSolarElevation(0,20);
		rd.setSolarElevation(0,21);
		rd.setSolarElevation(0,22);
		rd.setSolarElevation(0,23);
		
		rd.setSlopeAspectFactorHourly(0,0);
		rd.setSlopeAspectFactorHourly(0,1);
		rd.setSlopeAspectFactorHourly(0,2);
		rd.setSlopeAspectFactorHourly(0,3);
		rd.setSlopeAspectFactorHourly(0,4);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,6);
		rd.setSlopeAspectFactorHourly(1,7);
		rd.setSlopeAspectFactorHourly(1,8);
		rd.setSlopeAspectFactorHourly(1,9);
		rd.setSlopeAspectFactorHourly(1,10);
		rd.setSlopeAspectFactorHourly(1,11);
		rd.setSlopeAspectFactorHourly(1,12);
		rd.setSlopeAspectFactorHourly(1,13);
		rd.setSlopeAspectFactorHourly(1,14);
		rd.setSlopeAspectFactorHourly(1,15);
		rd.setSlopeAspectFactorHourly(1,16);
		rd.setSlopeAspectFactorHourly(1,17);
		rd.setSlopeAspectFactorHourly(1,18);
		rd.setSlopeAspectFactorHourly(1,19);
		rd.setSlopeAspectFactorHourly(0,20);
		rd.setSlopeAspectFactorHourly(0,21);
		rd.setSlopeAspectFactorHourly(0,22);
		rd.setSlopeAspectFactorHourly(0,23);
		
		HBDRLiuJordanHourlyStrategy algo = new HBDRLiuJordanHourlyStrategy();
		algo.setParameters(ljhParams);
		
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		double[] beamRes= {
							0,
							0,
							0,
							0,
							0,
							0.322,
							0.833,
							1.342,
							1.831,
							2.257,
							2.588,
							2.79,
							2.872,
							2.801,
							2.588,
							2.257,
							1.831,
							1.342,
							0.833,
							0.322,
							0,
							0,
							0,
							0
		};
		
		for(int h=0;h<24;h++) {// Assert, 1
			assertEquals("Beam",beamRes[h],XQMath.round(rd.getHourlyRadiationBeam(h),3),delta);
		}
		
	}
	public void testHBDRLiuJordanHourly2() {
		IRadData rd = new RadData();
		LiuJordanHourlyParameters ljhParams = new LiuJordanHourlyParameters();
		
		ljhParams.setHourlyLinkedTurbidityFactor(3);
		
		
		rd.setAlbedo(0.2);
		rd.setElevation(0,1,1); //Altitude  
		rd.setAngleSlope(0);
		rd.setClearSkyTransmissivity(0.75);
		rd.setCurrentDay(172);
		rd.setHourSunrise(5);
		rd.setHourSunset(19);
		
		rd.setGlobalSolarRadiationHourly(0,0);
		rd.setGlobalSolarRadiationHourly(0,1);
		rd.setGlobalSolarRadiationHourly(0,2);
		rd.setGlobalSolarRadiationHourly(0,3);
		rd.setGlobalSolarRadiationHourly(0,4);
		rd.setGlobalSolarRadiationHourly(0.36,5);
		rd.setGlobalSolarRadiationHourly(0.9,6);
		rd.setGlobalSolarRadiationHourly(1.43,7);
		rd.setGlobalSolarRadiationHourly(1.93,8);
		rd.setGlobalSolarRadiationHourly(2.36,9);
		rd.setGlobalSolarRadiationHourly(2.69,10);
		rd.setGlobalSolarRadiationHourly(2.89,11);
		rd.setGlobalSolarRadiationHourly(2.97,12);
		rd.setGlobalSolarRadiationHourly(2.9,13);
		rd.setGlobalSolarRadiationHourly(2.69,14);
		rd.setGlobalSolarRadiationHourly(2.36,15);
		rd.setGlobalSolarRadiationHourly(1.93,16);
		rd.setGlobalSolarRadiationHourly(1.43,17);
		rd.setGlobalSolarRadiationHourly(0.9,18);
		rd.setGlobalSolarRadiationHourly(0.36,19);
		rd.setGlobalSolarRadiationHourly(0,20);
		rd.setGlobalSolarRadiationHourly(0,21);
		rd.setGlobalSolarRadiationHourly(0,22);
		rd.setGlobalSolarRadiationHourly(0,23);
		
		rd.setSolarElevation(0,0);
		rd.setSolarElevation(0,1);
		rd.setSolarElevation(0,2);
		rd.setSolarElevation(0,3);
		rd.setSolarElevation(0,4);
		rd.setSolarElevation(0.114,5);
		rd.setSolarElevation(0.285,6);
		rd.setSolarElevation(0.466,7);
		rd.setSolarElevation(0.651,8);
		rd.setSolarElevation(0.833,9);
		rd.setSolarElevation(1.003,10);
		rd.setSolarElevation(1.138,11);
		rd.setSolarElevation(1.195,12);
		rd.setSolarElevation(1.138,13);
		rd.setSolarElevation(1.003,14);
		rd.setSolarElevation(0.833,15);
		rd.setSolarElevation(0.651,16);
		rd.setSolarElevation(0.466,17);
		rd.setSolarElevation(0.285,18);
		rd.setSolarElevation(0.114,19);
		rd.setSolarElevation(0,20);
		rd.setSolarElevation(0,21);
		rd.setSolarElevation(0,22);
		rd.setSolarElevation(0,23);
		
		rd.setSlopeAspectFactorHourly(0,0);
		rd.setSlopeAspectFactorHourly(0,1);
		rd.setSlopeAspectFactorHourly(0,2);
		rd.setSlopeAspectFactorHourly(0,3);
		rd.setSlopeAspectFactorHourly(0,4);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,6);
		rd.setSlopeAspectFactorHourly(1,7);
		rd.setSlopeAspectFactorHourly(1,8);
		rd.setSlopeAspectFactorHourly(1,9);
		rd.setSlopeAspectFactorHourly(1,10);
		rd.setSlopeAspectFactorHourly(1,11);
		rd.setSlopeAspectFactorHourly(1,12);
		rd.setSlopeAspectFactorHourly(1,13);
		rd.setSlopeAspectFactorHourly(1,14);
		rd.setSlopeAspectFactorHourly(1,15);
		rd.setSlopeAspectFactorHourly(1,16);
		rd.setSlopeAspectFactorHourly(1,17);
		rd.setSlopeAspectFactorHourly(1,18);
		rd.setSlopeAspectFactorHourly(1,19);
		rd.setSlopeAspectFactorHourly(0,20);
		rd.setSlopeAspectFactorHourly(0,21);
		rd.setSlopeAspectFactorHourly(0,22);
		rd.setSlopeAspectFactorHourly(0,23);
		
		HBDRLiuJordanHourlyStrategy algo = new HBDRLiuJordanHourlyStrategy();
		algo.setParameters(ljhParams);
		
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		double[] diffuseRes= {
				0,
				0,
				0,
				0,
				0,
				0.038,
				0.067,
				0.088,
				0.099,
				0.103,
				0.102,
				0.1,
				0.098,
				0.099,
				0.088,
				0.067,
				0.038,
				0,
				0,
				0,
				0
		};
		
		for(int h=0;h<24;h++) {//Assert, 2
			assertEquals("Diffuse",diffuseRes[h],rd.getHourlyRadiationDiffuseSky(h),delta);
		}
		
				
	}
	
	public void testHBDRLiuJordanHourly3() {
		IRadData rd = new RadData();
		LiuJordanHourlyParameters ljhParams = new LiuJordanHourlyParameters();
		
		ljhParams.setHourlyLinkedTurbidityFactor(3);
		
		
		rd.setAlbedo(0.2);
		rd.setElevation(0,1,1); //Altitude  
		rd.setAngleSlope(0);
		rd.setClearSkyTransmissivity(0.75);
		rd.setCurrentDay(172);
		rd.setHourSunrise(5);
		rd.setHourSunset(19);
		
		rd.setGlobalSolarRadiationHourly(0,0);
		rd.setGlobalSolarRadiationHourly(0,1);
		rd.setGlobalSolarRadiationHourly(0,2);
		rd.setGlobalSolarRadiationHourly(0,3);
		rd.setGlobalSolarRadiationHourly(0,4);
		rd.setGlobalSolarRadiationHourly(0.36,5);
		rd.setGlobalSolarRadiationHourly(0.9,6);
		rd.setGlobalSolarRadiationHourly(1.43,7);
		rd.setGlobalSolarRadiationHourly(1.93,8);
		rd.setGlobalSolarRadiationHourly(2.36,9);
		rd.setGlobalSolarRadiationHourly(2.69,10);
		rd.setGlobalSolarRadiationHourly(2.89,11);
		rd.setGlobalSolarRadiationHourly(2.97,12);
		rd.setGlobalSolarRadiationHourly(2.9,13);
		rd.setGlobalSolarRadiationHourly(2.69,14);
		rd.setGlobalSolarRadiationHourly(2.36,15);
		rd.setGlobalSolarRadiationHourly(1.93,16);
		rd.setGlobalSolarRadiationHourly(1.43,17);
		rd.setGlobalSolarRadiationHourly(0.9,18);
		rd.setGlobalSolarRadiationHourly(0.36,19);
		rd.setGlobalSolarRadiationHourly(0,20);
		rd.setGlobalSolarRadiationHourly(0,21);
		rd.setGlobalSolarRadiationHourly(0,22);
		rd.setGlobalSolarRadiationHourly(0,23);
		
		rd.setSolarElevation(0,0);
		rd.setSolarElevation(0,1);
		rd.setSolarElevation(0,2);
		rd.setSolarElevation(0,3);
		rd.setSolarElevation(0,4);
		rd.setSolarElevation(0.114,5);
		rd.setSolarElevation(0.285,6);
		rd.setSolarElevation(0.466,7);
		rd.setSolarElevation(0.651,8);
		rd.setSolarElevation(0.833,9);
		rd.setSolarElevation(1.003,10);
		rd.setSolarElevation(1.138,11);
		rd.setSolarElevation(1.195,12);
		rd.setSolarElevation(1.138,13);
		rd.setSolarElevation(1.003,14);
		rd.setSolarElevation(0.833,15);
		rd.setSolarElevation(0.651,16);
		rd.setSolarElevation(0.466,17);
		rd.setSolarElevation(0.285,18);
		rd.setSolarElevation(0.114,19);
		rd.setSolarElevation(0,20);
		rd.setSolarElevation(0,21);
		rd.setSolarElevation(0,22);
		rd.setSolarElevation(0,23);
		
		rd.setSlopeAspectFactorHourly(0,0);
		rd.setSlopeAspectFactorHourly(0,1);
		rd.setSlopeAspectFactorHourly(0,2);
		rd.setSlopeAspectFactorHourly(0,3);
		rd.setSlopeAspectFactorHourly(0,4);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,5);
		rd.setSlopeAspectFactorHourly(1,6);
		rd.setSlopeAspectFactorHourly(1,7);
		rd.setSlopeAspectFactorHourly(1,8);
		rd.setSlopeAspectFactorHourly(1,9);
		rd.setSlopeAspectFactorHourly(1,10);
		rd.setSlopeAspectFactorHourly(1,11);
		rd.setSlopeAspectFactorHourly(1,12);
		rd.setSlopeAspectFactorHourly(1,13);
		rd.setSlopeAspectFactorHourly(1,14);
		rd.setSlopeAspectFactorHourly(1,15);
		rd.setSlopeAspectFactorHourly(1,16);
		rd.setSlopeAspectFactorHourly(1,17);
		rd.setSlopeAspectFactorHourly(1,18);
		rd.setSlopeAspectFactorHourly(1,19);
		rd.setSlopeAspectFactorHourly(0,20);
		rd.setSlopeAspectFactorHourly(0,21);
		rd.setSlopeAspectFactorHourly(0,22);
		rd.setSlopeAspectFactorHourly(0,23);
		
		HBDRLiuJordanHourlyStrategy algo = new HBDRLiuJordanHourlyStrategy();
		algo.setParameters(ljhParams);
		
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		
		for(int h=0;h<24;h++) {//Assert, 3			
			assertEquals("Reflected",0,rd.getHourlyRadiationReflectedSoil(h),delta);
		}
		
	}
	
	public void testCSTWinslowEtAl() {
		IRadData rd = new RadData();
		WinslowEtAlParameters weaParams = new WinslowEtAlParameters();
		
		rd.setLatitude(10);
		rd.setAirTemperatureYearlyAverage(15.0);
		rd.setElevation(0.0,1,1); //Altitude.
		
		weaParams.setAerosolTransmittance(1.0);
		
		CSTWinslowEtAlStrategy algo = new CSTWinslowEtAlStrategy();
		algo.setParameters(weaParams);
		GSRadContext gsr = new GSRadContext((IAGSRadStrategy)algo);
		gsr.evaluate(rd);
		assertEquals("CST",0.82,XQMath.round(rd.getClearSkyTransmissivity(),2),delta);
		
		
		
	}
}

		

